package com.game;

import android.graphics.Canvas;

import com.javenwong.android.engine.GameCanvas;
import com.javenwong.android.engine.biology.Animation;

public class Role {
	protected byte id;

	protected int x, y;

	protected byte state;

	protected Animation[] anis = new Animation[16];

	protected Animation aniTemp;

	protected boolean loop;

	protected boolean actionEnd;

	/** 怪物攻击范围 */
	protected short attackW;
	/** 视野范围 */
	protected int seeW;

	public int hp, attack, recovery, skillAttack1, skillAttack2;

	public Role(int x, int y) {
		setPosition(x, y);
	}

	private void setPosition(int x2, int y2) {
		this.x = x2;
		this.y = y2;
	}

	public void logic() {
		if (aniTemp != null) { // 下一帧动画
			if (loop) {
				actionEnd = aniTemp.loopFrame(GameCanvas.timeCha);
			} else {
				actionEnd = aniTemp.nextFrame(GameCanvas.timeCha);
			}
		}
	}

	public void draw(Canvas g,int camera_X,int camera_Y) {
		if (aniTemp != null) {
			aniTemp.drawFrame(x-camera_X, y-camera_Y, g);
		}
	}

	public void setAttack(int attackPoint, byte dir, int x, int y) {
		// 掉灰
		// HitEffect he = new HitEffect(x, y);
		// gameView.hitEffectV.addElement(he);

		// 掉血
		HitPoint hit = new HitPoint(x, y - 20, dir, attackPoint);
//		gameView.hitPointV.addElement(hit);

		// 掉血
		// currentHp -= attackPoint;
	}

	public static void drawSpecial(Canvas g, int cameraX, int cameraY) {
//		for (int i = 0, s = gameView.hitPointV.size(); i < s; i++) {
//			HitPoint ani = (HitPoint) gameView.hitPointV.get(i);
//			ani.draw(g, cameraX, cameraY);
//			if (ani.isEnd()) {
//				gameView.hitPointV.removeElementAt(i);
//				s--;
//				i--;
//			}
//		}
	}

	public static void drawDie(Canvas g, int cameraX, int cameraY) {
//		for (int i = 0, s = gameView.dieV.size(); i < s; i++) {
//			HitDie die = (HitDie) gameView.dieV.get(i);
//			System.out.println("333333333333");
//			die.draw(g, cameraX, cameraY);
//			if (die.nextFrame()) {
//				gameView.dieV.remove(i);
//				s--;
//				i--;
//			}
//		}
	}

	public static void drawEffect(Canvas g, int cameraX, int cameraY) {
//		for (int i = 0, s = gameView.hitEffectV.size(); i < s; i++) {
//			HitEffect hit = (HitEffect) gameView.hitEffectV.get(i);
//			hit.draw(g, cameraX, cameraY);
//			if (hit.nextFrame()) {
//				gameView.hitEffectV.removeElementAt(i);
//				s--;
//				i--;
//			}
//		}
	}
}
